package com.sx.zongzhi.presenter;

import android.content.Context;

import com.sx.zongzhi.bean.MailBean;
import com.sx.zongzhi.modle.ApiManager;
import com.sx.zongzhi.modle.HeadParamBean;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.view.IInBoxDetailView;

import java.util.Map;

/**收件箱消息详情
 * Created by admin on 2017/12/1.
 */

public class InBoxDetailPest {
    private IInBoxDetailView iInBoxDetailView;

    public InBoxDetailPest(IInBoxDetailView iInBoxDetailView) {
        this.iInBoxDetailView=iInBoxDetailView;
    }
    //收件箱消息详情
    public void getInBoxDetail(Context context, String messageId){
        Map<String,Object> map = HeadParamBean.getHead(context);
        map.put("messageId", messageId);
        new ApiManager().getInBoxDetail(map, new BaseCallBack<BaseResult<MailBean>>() {
            @Override
            public void onSuccess(BaseResult<MailBean> response) {
                iInBoxDetailView.getInBoxDetailSuccess(response.getData());
            }
            @Override
            public void onFailures(String message) {
                iInBoxDetailView.showError(message);
            }
        });
    }
    //删除 消息
    public void deleteInBox(Context context, String messageId){
        Map<String,Object> map = HeadParamBean.getHead(context);
        map.put("messageId", messageId);
        new ApiManager().deleteInBox(map, new BaseCallBack<BaseResult<Boolean>>() {
            @Override
            public void onSuccess(BaseResult<Boolean> response) {
                iInBoxDetailView.deleteInBoxSuccess(response.getData());
            }
            @Override
            public void onFailures(String message) {
                iInBoxDetailView.deleteInBoxFail(message);
            }
        });
    }
}
